package com.dl.base.api.constant

import com.dl.base.utils.PreferencesUtil

object NetConstant {
    var HTTP_URL = "http://192.168.3.119:8000"
    var WEB_SOCKET_URL = "ws://192.168.3.119:8000"

    private const val KEY_HTTP_URL = "keyHttpUrl"
    private const val KEY_WEB_SOCKET_URL = "keyWebSocketUrl"

    /**
     * 请求成功状态码
     */
    const val RESULT_SUCCESS = "000000"

    /**
     * 请求失败状态码
     */
    const val RESULT_FAIL = 0

    fun getHttpUrl(): String {
        return PreferencesUtil.getString(KEY_HTTP_URL, HTTP_URL)
    }

    fun setHttpUrl(url: String) {
        PreferencesUtil.putObject(KEY_HTTP_URL, url)
    }

    fun getWebSocketUrl(): String {
        return PreferencesUtil.getString(KEY_WEB_SOCKET_URL, WEB_SOCKET_URL)
    }

    fun setWebSocketUrl(url: String) {
        PreferencesUtil.putObject(KEY_WEB_SOCKET_URL, url)
    }
}